package StudyCode.summary.regularexpressionsmatch;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UsingGroupsInRegularExpressions {
	public static void main(String[] args) {
		String regex = "\\b(\\d{3})\\d{7}\\b";
		String source = "1111111111, 1111111, and 1111111111";
		Pattern p = Pattern.compile(regex);

		Matcher m = p.matcher(source);

		while (m.find()) {

			String phone = m.group();
			String areaCode = m.group(1);
			System.out.println("电话: " + phone + ", 邮编: " + areaCode);
		}
	}
}
